//
//  XQAlbumModel.swift
//  PhotoSelect
//
//  Created by 王帅强 on 2019/1/7.
//  Copyright © 2019 王帅强. All rights reserved.
//

import UIKit
import Photos

class XQAlbumModel: NSObject {

    var collection: PHAssetCollection
    var assetsResult: PHFetchResult<PHAsset>?

    var name: String
    var count: Int {
        return assetsResult?.count ?? 0
    }


    init(with collection: PHAssetCollection, name: String) {

        self.collection = collection
        self.name = name

        let options = PHFetchOptions.init()
        options.sortDescriptors = [NSSortDescriptor.init(key: "creationDate", ascending: true)]
        self.assetsResult = PHAsset.fetchAssets(in: collection, options: options)

    }
}
